﻿<#include "/common/easyui-css.html">
<#include "/common/easyui-js.html">
<#include "/common/loading.html">
<script type="text/javascript" src="/lib/layer/2.4/layer.js"></script>
<body class="easyui-layout">

<div data-options="region:'center',border:false" style="padding:2px;height: auto">
	<table id="field_table" class="easyui-datagrid" title="" style="width:100%;height:100%;padding-bottom: 2px;"
		   data-options="rownumbers:true,
		   				   pagination:true,
		   				   singleSelect:true,
		   				   url:'/field-list-json/1/20',
          				   method:'get',
           			   toolbar:'#tb',
           			   fitColumns : true,
						   showFooter: true">
        <#include "/common/thead.html">
	</table>
</div>
<!-- 操作栏 -->
<div id="tb" style="padding:5px;height:auto">

    <div>
        实体类型:<input class="easyui-combobox" name="tableName"id="tableName"
               data-options="
				url : '/field-search-list',
				method: 'get',
				valueField:'value',
				textField:'text',
				">
        <a href="#" class="easyui-linkbutton" iconCls="icon-search" id="searchByParameter">搜索</a>
    </div>
    <div style="margin:5px 0;"></div>
   <#include "/common/button.html">
</div>

<!-- 条件查询 -->
<script type="text/javascript">
    $("#searchByParameter").click(function(){
        var tableName = $("#tableName").val();
        var handler = '/field-list-json/1/20?tableName='+tableName;
        $('#field_table').datagrid('options').url = handler;
        $('#field_table').datagrid('reload');
    });
</script>

<script type="text/javascript" src="/easyui/validatebox-extend.js"></script>
<div id="dlg" class="easyui-dialog" style="width:800px;" data-options="closed:true,modal:true,border:'thin',buttons:'#dlg-buttons'">
    <form id="fm" method="post" novalidate style="padding:2px 2px 2px 2px">
        <table class="dv-table" style="width:100%;background:#fafafa;padding:5px;margin-top:5px;">
			<tr>
				<td style="width: 20%">中文描述</td>
				<td style="width: 80%">
					<input name="fieldCn" id="fieldCn" validType="length[2,10]" class="easyui-textbox"  missingMessage="请输入中文描述" style="width:100%">
				</td>
			</tr>
        </table>
    </form>
</div>
<div id="dlg-buttons">
    <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="save()" style="width:90px">保存</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">取消</a>
</div>

<script>
	//编辑
        var url;
        //编辑
        $("#edit").click(function () {
            var row = $('#field_table').datagrid('getSelected');
            if (row){
                $('#dlg').dialog('open').dialog('center').dialog('setTitle','编辑');
                $('#fm').form('load',row);
                url = '/field-ins-upd-del/'+row.id;
            } else {
                layer.msg("请选择需要编辑的项目",{icon: 2})
            }
        });

        function save(){
            $('#fm').form('submit',{
                url: url,
                onSubmit: function(){
                    return $(this).form('validate');
                },
                success: function(result){
                    $('#dlg').dialog('close');        // close the dialog
                    $('#field_table').datagrid('reload');    // reload the user data
                }
            });
        }

</script>

<script type="text/javascript">
	$(function(){
		var p = $('#field_table').datagrid().datagrid('getPager');
		p.pagination({
			pageSize: 20, //每页显示的记录条数，默认为10
			pageList: [20, 25, 35], //可以设置每页记录条数的列表
			onSelectPage: function (pageNumber, pageSize) {
				var handler = '/field-list-json/'+pageNumber+'/'+pageSize;
				$('#field_table').datagrid('options').url = handler;
				$('#field_table').datagrid('reload');
			}
		});
	})
</script>


